package com.foldingleaf.web.controller.show;

import java.util.List;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.foldingleaf.common.annotation.Log;
import com.foldingleaf.common.core.controller.BaseController;
import com.foldingleaf.common.core.domain.Result;
import com.foldingleaf.common.enums.BusinessType;
import com.foldingleaf.show.domain.SysCollectionShow;
import com.foldingleaf.show.service.ISysCollectionShowService;
import com.foldingleaf.common.utils.poi.ExcelUtil;
import com.foldingleaf.common.core.page.TableDataInfo;

/**
 * 藏品出售展示Controller
 * 
 * @author ajian
 * @date 2022-05-30
 */
@Api(value = "/show/show", tags = {"藏品出售展示Controller"})
@RestController
@RequestMapping("/show/show")
public class SysCollectionShowController extends BaseController
{
    @Autowired
    private ISysCollectionShowService sysCollectionShowService;

    /**
     * 查询藏品出售展示列表
     */

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "SysCollectionShow", name = "sysCollectionShow", value = "")
    })
    @ApiOperation(value = "查询藏品出售展示列表", notes = "查询藏品出售展示列表", httpMethod = "GET")
    @GetMapping("/list")
    public TableDataInfo list(SysCollectionShow sysCollectionShow,@RequestHeader(value = "version",required = false) String version)
    {


        startPage();

        List<SysCollectionShow> list = sysCollectionShowService.selectSysCollectionShowList(sysCollectionShow);
        for (SysCollectionShow sysCollectionShow1 : list) {
            Long aLong = sysCollectionShowService.selectSysCollectionShowCount(sysCollectionShow1.getCollectionShowId());
            sysCollectionShow1.setRemainCount(aLong);
        }
        return getDataTable(list);
    }

    /**
     * 导出藏品出售展示列表
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "HttpServletResponse", name = "response", value = ""),
            @ApiImplicitParam(paramType = "query", dataType = "SysCollectionShow", name = "sysCollectionShow", value = "")
    })
    @ApiOperation(value = "导出藏品出售展示列表", notes = "导出藏品出售展示列表", httpMethod = "POST")
    @PreAuthorize("@ss.hasPermi('show:show:export')")
    @Log(title = "藏品出售展示", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCollectionShow sysCollectionShow)
    {
        List<SysCollectionShow> list = sysCollectionShowService.selectSysCollectionShowList(sysCollectionShow);
        ExcelUtil<SysCollectionShow> util = new ExcelUtil<SysCollectionShow>(SysCollectionShow.class);
        util.exportExcel(response, list, "藏品出售展示数据");
    }

    /**
     * 获取藏品出售展示详细信息
     *
     */

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "collectionShowId", value = "")
    })

    @ApiOperation(value = "获取藏品出售展示详细信息", notes = "获取藏品出售展示详细信息", httpMethod = "GET")
    @GetMapping(value = "/{collectionShowId}")
    public Result getInfo(@PathVariable("collectionShowId") Long collectionShowId)
    {
        Long aLong = sysCollectionShowService.selectSysCollectionShowCount(collectionShowId);
        SysCollectionShow sysCollectionShow = sysCollectionShowService.selectSysCollectionShowByCollectionShowId(collectionShowId);

        return Result.success(sysCollectionShow).put("count", aLong);
    }

    /**
     * 新增藏品出售展示
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "SysCollectionShow", name = "sysCollectionShow", value = "")
    })
    @ApiOperation(value = "新增藏品出售展示", notes = "新增藏品出售展示", httpMethod = "POST")
    @PreAuthorize("@ss.hasPermi('show:show:add')")
    @Log(title = "藏品出售展示", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody SysCollectionShow sysCollectionShow)
    {
        return toAjax(sysCollectionShowService.insertSysCollectionShow(sysCollectionShow));
    }

    /**
     * 修改藏品出售展示
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "SysCollectionShow", name = "sysCollectionShow", value = "")
    })
    @ApiOperation(value = "修改藏品出售展示", notes = "修改藏品出售展示", httpMethod = "PUT")
    @PreAuthorize("@ss.hasPermi('show:show:edit')")
    @Log(title = "藏品出售展示", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody SysCollectionShow sysCollectionShow)
    {
        return toAjax(sysCollectionShowService.updateSysCollectionShow(sysCollectionShow));
    }

    /**
     * 删除藏品出售展示
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "Long[]", name = "collectionShowIds", value = "")
    })
    @ApiOperation(value = "删除藏品出售展示", notes = "删除藏品出售展示", httpMethod = "DELETE")
    @PreAuthorize("@ss.hasPermi('show:show:remove')")
    @Log(title = "藏品出售展示", businessType = BusinessType.DELETE)
	@DeleteMapping("/{collectionShowIds}")

    public Result remove(@PathVariable Long[] collectionShowIds)
    {
        return toAjax(sysCollectionShowService.deleteSysCollectionShowByCollectionShowIds(collectionShowIds));
    }
}
